import time

from selenium.webdriver.common.by import By
from pom.base_page import BasePage


class OrderManagePage(BasePage):
    def user_order(self):
        self.driver.find_element(By.XPATH, '//div[2]/div/div[1]/div[2]/div[1]/div/ul/div[11]/li/ul/div[1]/a/li').click()

        time.sleep(2)
        order = self.driver.find_element(By.XPATH, '//div[2]/div/div[2]//div/div[2]/div[3]//tr[1]/td[3]/div').text
        goods = self.driver.find_element(By.XPATH, '//div[2]/div/div[2]//div/div[2]/div[3]//tr[1]/td[4]/div').text
        en_name = self.driver.find_element(By.XPATH, '//div[2]/div/div[2]//div/div[2]/div[3]//tr[1]/td[12]/div').text
        print(order, goods, en_name)

        assert order == "202212020949117u4i"
        assert goods == "23"
        assert en_name == "Message Template"

    def payment_order(self):
        self.driver.find_element(By.XPATH, '//div[2]/div/div[1]/div[2]/div[1]/div/ul/div[11]/li/ul/div[2]/a/li').click()

        time.sleep(2)

    def income_statistics(self):
        self.driver.find_element(By.XPATH, '//div[2]/div/div[1]/div[2]/div[1]/div/ul/div[11]/li/ul/div[3]/a/li').click()

        time.sleep(2)

    def order_operation(self):
        self.driver.find_element(By.XPATH, '//div[2]/div/div[1]/div[2]/div[1]/div/ul/div[11]/li/ul/div[4]/a/li').click()

        time.sleep(2)
        create_time = self.driver.find_element(By.XPATH, '//div[2]/div/div[2]//div/div[2]/div[3]//tr/td[4]/div/span').text
        category = self.driver.find_element(By.XPATH, '//div[2]/div/div[2]//div/div[2]/div[3]//tr/td[6]/div/span').text
        print(create_time, category, "****************")

        assert create_time == "2022-11-23"
        assert category == "其他"
